package com.learn.retry;

import com.learn.retry.service.RetryComponent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

@Slf4j
@SpringBootTest
public class SpringBootRetryApplicationTest {

    @Resource
    private RetryComponent retryComponent;

    @Test
    void sendSmsTest() {
        boolean ret = retryComponent.sendSmsRetry();
        log.info("sendSmsTest result = {}", ret);
    }

    @Test
    public void enumTest() {


        Month m1 = Month.JAN;
        Month m2 = Month.FEB;
        Month m3 = Month.MAR;
        Month m4 = Month.APR;
        Month m5 = Month.MAY;

        System.out.println("m1.ordinal() " + " " + m1.ordinal());
        System.out.println("m2.ordinal()" + " " + m2.ordinal());
        System.out.println("m3.ordinal()" + " " + m3.ordinal());
        System.out.println("m4.ordinal()" + " " + m4.ordinal());
        System.out.println("m5.ordinal()" + " " + m5.ordinal());
    }

    /**
     * 月份
     */
    enum Month {

        JAN,
        FEB,
        MAR,
        APR,
        MAY;
    }


    @Test
    public void EmpStatusTest() {

        int ON_POST = EmpStatusEnum.ON_POST.ordinal();
        int post = EmpStatusEnum.ON_POST.empStatus;
        System.out.println("在职:" + ON_POST);
        System.out.println("在职post:" + post);
    }

    @Getter
    @AllArgsConstructor
    enum EmpStatusEnum {

        /**
         * 1：在职
         */
        ON_POST(1, "在职"),
        /**
         * 2：离职
         */
        RESIGN(2, "离职"),
        /**
         * 3：退休
         */
        RETIRE(3, "退休"),
        /**
         * 4:其他
         */
        OTHER(4, "其他");


        private Integer empStatus;

        private String statusName;

        public static EmpStatusEnum valueByStatusName(String empStatus) {
            for (EmpStatusEnum empStatusEnum : EmpStatusEnum.values()) {
                if (empStatusEnum.empStatus.equals(empStatus)) {
                    return empStatusEnum;
                }
            }
            return null;
        }
    }


}